package tech.tongyu.bct.omssdk.controller;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.tongyu.bct.market.dto.SwapInstrumentWhiteListDTO;
import tech.tongyu.bct.omssdk.entity.Result;
import tech.tongyu.bct.omssdk.service.IsolationWallService;
import tech.tongyu.idp.model.OmsSecurityPool;
import tech.tongyu.idp.model.OmsSystem;

import java.util.Arrays;
import java.util.List;

/**
 * 触发隔离墙同步数据到对冲台
 */
@RestController
@RequiredArgsConstructor
@RequestMapping
public class IsolationWallSyncController {

    @Autowired
    private IsolationWallService isolationWallService;
    @PostMapping("/oms-sdk/syncIsolationWall")
    public Result syncIsolationWall() {
        List<SwapInstrumentWhiteListDTO> swapInstrumentWhiteList = isolationWallService.getSwapInstrumentWhiteList();
        List<OmsSecurityPool> omsSecurityPools = isolationWallService.completeSecurityPool(swapInstrumentWhiteList, OmsSystem.OMS_SH_1, Arrays.asList("禁止交易_全局_买", "禁止交易_全局_卖"));
        isolationWallService.completeRiskControlRule(omsSecurityPools);
        return Result.success();
    }
}
